package com.chenx.gameview;

import java.util.ArrayList;
import java.util.List;

import android.graphics.Bitmap;

import com.chenx.gameinterface.GameImage;

public class FeJiImage implements GameImage
{

	private int display_w, display_h;
	private Bitmap my;
	private int index = 0;
	private int changenum = 0;
	private List<Bitmap> bitmaps = new ArrayList<Bitmap>();
	private int x, y, width, height;

	public FeJiImage(Bitmap my, int display_w, int display_h)
	{
		this.display_w = display_w;
		this.display_h = display_h;

		this.my = my;
		bitmaps.add(Bitmap.createBitmap(my, 0, 0, my.getWidth() / 4,
				my.getHeight()));
		bitmaps.add(Bitmap.createBitmap(my, (my.getWidth() / 4) * 1, 0,
				my.getWidth() / 4, my.getHeight()));
		bitmaps.add(Bitmap.createBitmap(my, (my.getWidth() / 4) * 2, 0,
				my.getWidth() / 4, my.getHeight()));
		bitmaps.add(Bitmap.createBitmap(my, (my.getWidth() / 4) * 3, 0,
				my.getWidth() / 4, my.getHeight()));

		// 得到战机宽高
		width = my.getWidth() / 4;
		height = my.getHeight();

		x = (display_w - my.getWidth() / 4) / 2;
		y = display_h - my.getHeight() - 20;
	}

	@Override
	public int getX()
	{
		// TODO Auto-generated method stub
		return x;
	}

	@Override
	public int getY()
	{
		// TODO Auto-generated method stub
		return y;
	}

	@Override
	public Bitmap getBitmap()
	{
		Bitmap bitmap = bitmaps.get(index);

		if (changenum == 7)
		{
			index++;
			if (index == bitmaps.size())
			{
				index = 0;
			}
			changenum = 0;
		}
		changenum++;

		return bitmap;
	}

	public int getWidth()
	{
		return width;
	}

	public int getHeight()
	{
		return height;
	}

	public void setX(int x)
	{
		this.x = x;
	}

	public void setY(int y)
	{
		this.y = y;
	}
}
